package calvin.study.rabbitmq.advanced.return_queue;

import java.util.HashMap;
import java.util.Map;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;

import calvin.study.rabbitmq.base.RabbitMqBase;

public class Producer extends RabbitMqBase {

	public static void main(String[] args) throws Exception {
		Channel channel = getChannel();
		String exchange = "topic_exchange";
		String routingKey = "returnqueue.notice.save";
		
		Map<String, Object> headers  = null;
		
		for (int i = 0; i < 5; i++) {
			headers = new HashMap< String, Object>();
			headers.put("num", i);
			// 设置消息属性
			//expiration 消息的过期时间
			AMQP.BasicProperties properties = new AMQP.BasicProperties.Builder().deliveryMode(2).expiration("3000")
					.contentEncoding("UTF-8").headers(headers).build();
			String msg = "Hello RabbitMQ ACK Message " + i;
			
			channel.basicPublish(exchange, routingKey, properties, msg.getBytes());
		}
		//close();
	}

}
